#include "header.h"

static double c1, c2, c3, c4;
static double d1, d2, d3, d4;

void init_splitstep()
{
  d1 = 1 / ( 2 - pow(2, 1/3.) );
  d3 = d1;
  d2 = 1 - (d1+d3);

  c1 = 0.5 * d1;
  c2 = 0.5 - c1;
  c3 = 0.5 - c1;
  c4 = c1;

}

void s_order(ctrl_ptr ctrl, work_ptr in)
{
    //lin_step(in, 0.5*step(ctrl) );
    MPI_Barrier(COMM);  
    if ((ctrl->mFlag) == 1) mask(in);
    nnl_step(in, 1.*step(ctrl) );
    MPI_Barrier(COMM);  
    if ((ctrl->mFlag) == 1) mask(in); 
    lin_step(in, 1.*step(ctrl) );
    MPI_Barrier(COMM);  
}
void f_order(ctrl_ptr ctrl, work_ptr in)
{
  //nnl_step(in, c1*step(ctrl));
  MPI_Barrier(COMM);  
  lin_step(in, d1*step(ctrl));
  MPI_Barrier(COMM);  
  nnl_step(in, c2*step(ctrl));
  MPI_Barrier(COMM);  
  lin_step(in, d2*step(ctrl));
  MPI_Barrier(COMM);  
  nnl_step(in, c3*step(ctrl));
  MPI_Barrier(COMM);  
  lin_step(in, d3*step(ctrl));
  MPI_Barrier(COMM);  
  nnl_step(in, (c4+c1)*step(ctrl));
  MPI_Barrier(COMM);  
}
